package java.wxw;

import java.util.Scanner;
import java.wxw.Final;
/**
 * @author songzihan
 * @create 2020--07--03
 */
public class Delete extends Final{
    private static String deleteFileName;
    FileExist fileExist = new FileExist();
    FindPANo findPANo = new FindPANo();
    DirExist dirExist = new DirExist();
    public  void delete(){

            if(dirName.toUpperCase().equals(userName.toUpperCase())){
              System.out.println("Error!You must delete in your own dir");
           }else{
                System.out.println("Please input FileName: ");
                Scanner in = new Scanner(System.in);
                if (in.hasNext()){
                    deleteFileName =  in.next();
                }
                int i = fileExist.fileExsit(deleteFileName);
                if (i!=-1){
                    int k = dirExist.dirExist(deleteFileName);
                    if(openIf[k][i].openMode==3){
                        System.out.println("This is a protected file, it can not be deleted.");
                    }else{
                        if(openIf[k][i].openMode==1){
                            System.out.println("File has been opened, it can not be deleted");
                        }else {
                            //填写删除逻辑代码
                            System.out.println("File  has been deleted successfully!");
                        }
                    }

                }else {
                    System.out.println("file does not exist");
                }
            }
        }
    }


